﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace TSCL.Web.article
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtmenuid.Text))
			{
				strErr+="menuid格式错误！\\n";	
			}
			if(this.txtarticletitle.Text.Trim().Length==0)
			{
				strErr+="articletitle不能为空！\\n";	
			}
			if(this.txtarticleceater.Text.Trim().Length==0)
			{
				strErr+="articleceater不能为空！\\n";	
			}
			if(this.txtarticlecontent.Text.Trim().Length==0)
			{
				strErr+="articlecontent不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtpubtime.Text))
			{
				strErr+="pubtime格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtispub.Text))
			{
				strErr+="ispub格式错误！\\n";	
			}
			if(this.txtremarks.Text.Trim().Length==0)
			{
				strErr+="remarks不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txttagid.Text))
			{
				strErr+="tagid格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int menuid=int.Parse(this.txtmenuid.Text);
			string articletitle=this.txtarticletitle.Text;
			string articleceater=this.txtarticleceater.Text;
			string articlecontent=this.txtarticlecontent.Text;
			DateTime pubtime=DateTime.Parse(this.txtpubtime.Text);
			int ispub=int.Parse(this.txtispub.Text);
			string remarks=this.txtremarks.Text;
			int tagid=int.Parse(this.txttagid.Text);

			TSCL.Model.article model=new TSCL.Model.article();
			model.menuid=menuid;
			model.articletitle=articletitle;
			model.articleceater=articleceater;
			model.articlecontent=articlecontent;
			model.pubtime=pubtime;
			model.ispub=ispub;
			model.remarks=remarks;
			model.tagid=tagid;

			TSCL.BLL.article bll=new TSCL.BLL.article();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
